<template>
  <div>
    周浩宇真的帅
    {{ $store.state.num }}
    <br />
    getters:
    {{ $store.getters.num }}
    <br />
    <button @click="btn">按钮</button>
    <button @click="btn1">按钮异步</button>
  </div>
</template>

<script>
export default {
  data () {
    return {}
  },
  created () {
    this.getData()
  },
  methods: {
    getData () {
      console.log(this.$store.state.num)
    },
    btn () {
      this.$store.commit('numFn', '1', '2')
    },
    btn1 () {
      this.$store.dispatch('numFnSync', '1', '2')
      /*
        this.$store.state.num
        this.$store.getters.num
        this.$store.commit('函数名',传递的参数)
        this.$store.dispatch('异步函数名',传递的参数)
      */
    }
  }
}
</script>

<style></style>
